/**
 * @Author ZhangCuirong
 * @Date 2025/8/12 11:20
 * @description:
 */
public class Solution27 {
    public int removeElement(int[] nums, int val) {
        int left = 0, right = 0;
        while (right < nums.length) {
            if (nums[right] == val) {
                right++;
            } else {
                nums[left] = nums[right];
                left++;
                right++;
            }
        }
        return left;
    }

    public static void main(String[] args) {
        int[] nums = {3, 2, 2, 3};
        int val = 3;
        Solution27 solution = new Solution27();
        int res = solution.removeElement(nums, val);
        System.out.println(res);
    }
}
